﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<InternshipManagement.Helpers.PaginatedList<InternshipManagement.Models.Announcement>>" %>
<%@ Import Namespace="InternshipManagement.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    List
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% 
        
        ViewBag.AnnouncementOp = 1;
        Html.RenderPartial("AnnouncementMenu"); 
    %>
    <table class="list">
        <tr>
            <th>
                Title
            </th>
            <th style="width:30%">
                Sent Date
            </th>
            <th style="width: 110px;">
                Actions
            </th>
        </tr>
        <%
            bool odd = false;
            foreach (var item in Model)
            {
                odd = !odd;
        %>
        <tr class='<%=odd?"odd":"even" %>'>
            <td>
                <%=item.Title%>
            </td>
            <td>
                <%=item.SentDate.Value.ToShortDateString()%>
            </td>
            <td>
                <div class="actions_menu">
                    <ul>
                        <% if (((List<int>)Session["UserPrivileges"]).Contains((int)UserPrivileges.EditAnnouncement))
                           {%>
                        <li>
                            <%=Html.ActionLink("Edit", "Edit", new { id = item.ID }, new { @class = "edit" })%>
                        </li>
                        <%} if (((List<int>)Session["UserPrivileges"]).Contains((int)UserPrivileges.DeleteAnnouncement))
                           {%>
                        <li>
                            <%=Html.ActionLink("Delete", "Delete", new { Id = item.ID }, new { @class = "delete" })%>
                        </li>
                        <%} %>
                    </ul>
                </div>
            </td>
        </tr>
        <% } %>
        <tr class='<%=odd?"even":"odd" %>'>
            <td colspan="3">
                <span class="prevpage">
                    <% if (Model.HasPreviousPage)
                       { %>
                    <%: Html.ActionLink("Previous Page",
                               "List", 
                               new { page=(Model.PageIndex-1) }) %>
                    <% } %>
                </span>
                <span class="nextpage">
                    <% if (Model.HasNextPage)
                       { %>
                    <%: Html.ActionLink("Next Page", 
                               "List", 
                               new { page=(Model.PageIndex+1) }) %>
                    <% } %>
                </span>
            </td>
        </tr>
    </table>
    <div id="dialog" title="Remove the student?">
        Are you sure you want to remove this student?
    </div>

</asp:Content>
